package gray.boolber.vk.web.api.utils;

import android.os.Environment;

public class StorageManager {
	private final static String rootBoolberFolder="/Android/data/com.boolber.android";
	private final static String cacheBoolberFolder="/cache";
    
	public static String getExternalStoragePath(){
		String path=null;
		checkExternalStorage();
		if(mExternalStorageAvailable && mExternalStorageWriteable){
			path=Environment.getExternalStorageDirectory().getAbsolutePath();
			path=path+rootBoolberFolder+cacheBoolberFolder;
		}
		return path;
	}
	private static boolean mExternalStorageAvailable;
	private static boolean mExternalStorageWriteable;
	private static void checkExternalStorage(){
		String state = Environment.getExternalStorageState();

		if (Environment.MEDIA_MOUNTED.equals(state)) {
		    mExternalStorageAvailable = mExternalStorageWriteable = true;
		} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
		    mExternalStorageAvailable = true;
		    mExternalStorageWriteable = false;
		} else {
		    mExternalStorageAvailable = mExternalStorageWriteable = false;
		}
	}

}
